package com.pcjavanet.generate;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;

public abstract class CreateClassTemplate {

	private Field  fs[];
	private Class cls;
	private List<String> importContent = new ArrayList<String>();
	private String packagepath ="package com.pcjavanet.web.action;\r\n";
	private String basepackagepath = "";
	public String getBasepackagepath() {
		return basepackagepath;
	}
	public List<String> getImportContent() {
		return importContent;
	}
	public void setImportContent(List<String> importContent) {
		this.importContent = importContent;
	}
	public void setBasepackagepath(String basepackagepath) {
		this.basepackagepath = basepackagepath;
	}
	public abstract String createFieldsDefineStr();
	public String getPackagepath() {
		return packagepath;
	}
	public void setPackagepath(String packagepath) {
		this.packagepath = packagepath;
	}
	public abstract String createActionMethodByName(String methodName);
	public abstract String createGetSetMethodStr();
	public abstract String createImportStr();
	public abstract String createBodyBegin();
	public abstract String createInsertMethod();
	public abstract String createQueryMethod();
	public abstract String createUpdateMethod();
	public abstract String createDeleteMethod();
	public abstract String createListMethod();
	public abstract String createBeanServiceStr();
	public String createPackageStr(){
		return packagepath;
	}
//	public String createBeanServiceStr(){
//		StringBuffer buf = new StringBuffer();
//		String name = getCls().getSimpleName();
//		name = name.substring(0, 1).toLowerCase()+name.substring(1, name.length());
//		buf.append("  private ").append(" ").append( getCls().getSimpleName()).append("Servicve").append(" ").append(name).append("Service;\r\n");
//		buf.append("  public void set").append( getCls().getSimpleName()).append("(").append( getCls().getSimpleName()).append("Servicve service){\r\n");
//		buf.append("     this.").append(name).append("Service=service;\r\n");
//		buf.append("  }\r\n");
//		return buf.toString();
//	}
	public String createBodyEnd(){
		StringBuffer buf = new StringBuffer();
		buf.append("}\r\n");
		return buf.toString();
	}
	public Field[] getFs() {
		return fs;
	}
	public Class getCls() {
		return cls;
	}
	public void setCls(Class cls) {
		this.cls = cls;
	}
	public void setFields(Field[] fs) {
		this.fs = fs;
	}
	
 
	public String createClass(){
		StringBuffer buf = new StringBuffer();
		buf.append( createPackageStr());
		buf.append("\r\n");
		buf.append(createImportStr());
		buf.append("\r\n");
		buf.append(createBodyBegin());
		buf.append("\r\n");
		buf.append(createFieldsDefineStr());
//		buf.append("\r\n");
		buf.append( createGetSetMethodStr());
//		buf.append("\r\n");
		buf.append( createBeanServiceStr());
		buf.append("\r\n");
		buf.append( createInsertMethod());
		buf.append("\r\n");
		buf.append( createQueryMethod());
		buf.append("\r\n");
		buf.append( createUpdateMethod());
		buf.append("\r\n");
		buf.append( createDeleteMethod());
		buf.append("\r\n");
		buf.append( createListMethod());
		buf.append("\r\n");
		buf.append(createBodyEnd());
		return buf.toString();
	}
 
}
